package com.example.demo.service.impl;

import com.example.demo.dao.UserDoMapper;
import com.example.demo.dao.UserPasswordDOMapper;
import com.example.demo.dataObject.UserDo;
import com.example.demo.dataObject.UserPasswordDO;
import com.example.demo.service.UserService;
import com.example.demo.service.module.UserModule;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDoMapper userDoMapper;


    @Autowired

    private UserPasswordDOMapper userPasswordDOMapper;
    @Override
    public UserModule getUserById(Integer id) {
        UserDo userDo=userDoMapper.selectByPrimaryKey(id);
        UserPasswordDO userPasswordDO=userPasswordDOMapper.selectByPrimaryKey(id);
        return  convertFromDataObject(userDo,userPasswordDO);
    }

    private  UserModule convertFromDataObject(UserDo userDo, UserPasswordDO userPasswordDO){
        UserModule userModule=new UserModule();
        BeanUtils.copyProperties(userDo,userModule);
        userModule.setEncrptPaddword(userPasswordDO.getEncrptPassword());
        return userModule;
    }
}
